﻿using System;

namespace WholeSlideImageLibrary.DeepZoom
{
    public readonly struct DeepZoomProfile : IEquatable<DeepZoomProfile>
    {
        public DeepZoomProfile(short tileSize, short overlap, EncodedImageFileFormat fileFormat)
        {
            TileSize = tileSize;
            Overlap = overlap;
            FileFormat = fileFormat;
        }

        public static DeepZoomProfile Default => new DeepZoomProfile(256, 0, EncodedImageFileFormat.Jpeg);

        public short TileSize { get; }
        public short Overlap { get; }
        public EncodedImageFileFormat FileFormat { get; }

        public static bool operator ==(DeepZoomProfile left, DeepZoomProfile right) => left.Equals(right);
        public static bool operator !=(DeepZoomProfile left, DeepZoomProfile right) => !left.Equals(right);

        public override bool Equals(object? obj)
        {
            return obj is DeepZoomProfile profile &&
                   TileSize == profile.TileSize &&
                   Overlap == profile.Overlap &&
                   FileFormat == profile.FileFormat;
        }

        public bool Equals(DeepZoomProfile other)
        {
            return TileSize == other.TileSize &&
                  Overlap == other.Overlap &&
                  FileFormat == other.FileFormat;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(TileSize, Overlap, FileFormat);
        }
    }
}
